<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!-- 
	파일명 : addSubCommonCode_p.jsp
	성명 : Yang D
 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="attend.com.CodeMetrix"%><html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>하위코드 추가</title>
<link rel="stylesheet" type="text/css" href="/inc/css/common.css" />
<script type="text/javascript" src="/inc/css/common.js"></script>
<script language="javascript">
	window.name = "codetale";
	
	//저장버튼
/*	function saveSubCommonCode() {
	
		var cd 				= form.cd.value;
		var full_nm 		= form.full_nm.value;
		var checkedUseyn 	= form.checkedUseyn.value;

		//대표코드 선택
		if (form.group_cd.value.length == 0) {
			form.group_cd.focus();
			alert("대표코드명을 선택하시기 바랍니다.");
			
			return false;
		}

		//하위코드 미입력시
		if(cd == "") {
			alert("<s:text name="alert.message.requiedCode" />");
			form.cd.focus();
			return false;
		}
		var cnt=0;
		for(var i=0; i<cd.length; i++){
           if(cd.charAt(i)== " "){
                 cnt++;
           }
		}
		if(cd.length == cnt){
           alert("코드에 공백을 허용하지 않습니다.");
           form.cd.focus();
           return false;
		}
		//하위코드에 0을 입력하였을시
		if(cd == "0") {
			alert("<s:text name="alert.message.exclusionZeo" />");
			form.cd.focus();
			return false;
		}

		//코드명 미입력시
		if(full_nm == "") {
			alert("<s:text name="alert.message.requiedCodeName" />");
			form.full_nm.focus();
			return false;
		}
		var count=0;
		for(var i=0; i<full_nm.length; i++){
           if(full_nm.charAt(i)== " "){
                 count++;
           }
		}
		if(full_nm.length == cnt){
           alert("코드명에 공백을 허용하지 않습니다.");
           form.full_nm.focus();
           return false;
		}
		//사용유무 미사용시
		if(checkedUseyn == "") {
			alert("<s:text name="alert.message.use_yn" />");
			form.checkedUseyn.focus();
			return false;
		}

		if (confirm("<s:text name="alert.message.questionSave" />")) {
			document.form.action="attendSaveSubCommonCode_p.action";
			document.form.submit();
			return false;
		}
		
	} */


	function saveSubCommonCode() {
		
		var cd 				= form.cd.value;
		var full_nm 		= form.full_nm.value;
		var checkedUseyn 	= form.checkedUseyn.value;

		//대표코드 선택
		if (form.group_cd.value.length == 0) {
			form.group_cd.focus();
			alert("대표코드명을 선택하시기 바랍니다.");
			
			return false;
		}

		//하위코드 미입력시
		if(cd == "" || full_nm == "") {
           if(cd==""){
			alert("<s:text name="alert.message.requiedCode" />");
			form.cd.focus();
			return false;
           }
           if(full_nm == ""){
        	alert("코드명을 입력하시기 바랍니다.");
   			form.cd.focus();
   			return false;
           }
		}
	    if(cd.search(/\s/g)>-1  ||  full_nm.search(/\s/g)>-1 ){
           alert("공백을 허용하지 않습니다.");
           if(cd.search(/\s/g)>-1){
        	   form.cd.focus();
        	   return false;
           }
           if(full_nm.search(/\s/g)>-1 ){
               form.full_nm.focus();
               return false;
           }
	    }
        
		//하위코드에 0을 입력하였을시
		if(cd == "0") {
			alert("<s:text name="alert.message.exclusionZeo" />");
			form.cd.focus();
			return false;
		}
      
		
		
		//사용유무 미사용시
		if(checkedUseyn == "") {
			alert("<s:text name="alert.message.use_yn" />");
			form.checkedUseyn.focus();
			return false;
		}

		if (confirm("<s:text name="alert.message.questionSave" />")) {
			document.form.action="attendSaveSubCommonCode_p.action";
			document.form.submit();
			return false;
		}
		
	}
	
	//화면 로딩시
	window.onload = function() {
		//-----------------------------------------------------------------------//
		if ("<s:property value="msg"/>" == "<%=CodeMetrix.OK %>") {
			alert("저장이 완료되었습니다.");
			window.close();
			opener.call_dojo();
		} else if("<s:property value="msg"/>" == "<%=CodeMetrix.DUPLICATE %>") {
			alert("이미 입력된 하위코드가 있습니다.");
		}

	}
	
</script>
</head>
<body >

<s:form name="form" id="form" theme="simple" >
	<div id="popup_550se_top"></div>
		<div id="popup_550se_bg">
			<table class="pop550se_Tbl">
			<tr>
				<th>대표코드명</th>
				<td>
					<s:select name="group_cd" id="group_cd" list="listGroupCode" headerKey="" headerValue="::선택::"  listKey="group_cd" listValue="cd_nm" cssClass="combobox120se" />
				</td>
			</tr>
			<tr>
				<th>코드</th>
				<td>
					<input type="text" name="cd" value="<s:property value="cd" />" class="input_120se" maxlength="8" />
				</td>
				<th>코드명</th>
				<td>
					<input type="text" name="full_nm" value="<s:property value="full_nm" />" class="input_120se" maxlength="20"></input>		
				</td>
			</tr>
			<tr>
				<th>사용여부</th>
				<td>
					<s:select name="checkedUseyn"   headerKey="" headerValue="::선택::" list="#{'Y':'Y','N':'N'}" cssClass="combobox120se"/>		
				</td>
			</tr>	
			</table>
			
		<div id="popup_btn"><s:submit type="image" src="/images/btn_save.gif" onclick="return saveSubCommonCode();"/></div>
	</div>
	
	<!---------------Bottom : STR----------->
	<div id="popup_550se_bottom"><s:submit type="image" src="/images/pop_btn_close.gif" onclick="window.close();"/></div>
	<!---------------Bottom : END----------->
	<!-- ajax dummy -->
		<s:url id="temp_list"  action="codetable_ajax_dummy" />
		<s:div id="tempDiv" theme="ajax" executeScripts="true" showLoadingText="false" href="%{temp_list}" listenTopics="ajaxDojo" formId="form" />
</s:form>
</body>
</html>
